import 'reflect-metadata'
import {MethodType} from '../types';

// 封装方法装饰器
function reqMethodDecorator(methodType: MethodType) {
    return function (path: string) {
        return function (targetPrototype: any, methodname: string) {
            console.log("执行方法装饰器：执行的类是==>", targetPrototype.constructor, " 方法是==>", methodname);

            //将方法路径和方法类型保存到方法元数据中
            Reflect.defineMetadata('path', path, targetPrototype, methodname);
            Reflect.defineMetadata('methodType', methodType, targetPrototype, methodname);
        }
    }
}

export const get = reqMethodDecorator("get");
export const post = reqMethodDecorator("post");
